package com.ymxx.jweb.persistence.organization;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

/**
 * @author Administrator
 * 员工信息实体
 */
@Entity
@Table(name="YMXX_EMPLOYEE")
public class Employee {

	/**
	 * 员工唯一标志
	 */
	@Id
	@Column(name="UUID",length=128)
	@GeneratedValue(generator="system-uuid")
	@GenericGenerator(name="system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
	private String uuid;
	/**
	 * 员工姓名
	 */
	@Column(name="NAME",length=40,nullable=false)
	private String name;
	/**
	 * 员工编号
	 */
	@Column(name="CODE",unique=true,updatable=false)
	private String code;
	/**
	 * 状态
	 */
	@Column(name="STATUS")
	public Integer status;
	/**
	 * 电子邮箱
	 */
	@Column(name="EMAIL")
	private String email;
	/**
	 * 用户密码
	 */
	@Column(name="PASSWORD")
	private String password; 
	/**
	 * 头衔
	 */
	@Column(name="TITLE")
	private String title;
	/**
	 * 员工年龄
	 */
	@Column(name="AGE")
	private Integer age;
	/**
	 * 员工的性别
	 */
	@Column(name="GENDER",length=8)
	private String gender;
	/**
	 * 员工的工资
	 */
	@Column(name="SALARY")
	private Double salary;
	/**
	 * 出生日期
	 */
	@Column(name="BIRTH")
	@Temporal(TemporalType.DATE)
	private Date birth;
	/**
	 * 部门经理
	 * optional 标识外键是否可以为空
	 */
	@ManyToOne(fetch=FetchType.LAZY,optional=true)
	@JoinColumn(name="MANAGER_UUID")
	private Employee manager;
	/**
	 * 手下员工
	 */
	@OneToMany(mappedBy="manager",cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Employee> employees;
	/**
	 * 所在部门
	 */
	@ManyToOne(fetch=FetchType.LAZY,optional=false)
	@JoinColumn(name="DEPT_UUID")
	private Department dept;
	public Employee() {
		super();
	}
	public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public Double getSalary() {
		return salary;
	}
	public void setSalary(Double salary) {
		this.salary = salary;
	}
	public Employee getManager() {
		return manager;
	}
	public void setManager(Employee manager) {
		this.manager = manager;
	}
	public List<Employee> getEmployees() {
		return employees;
	}
	public void setEmployees(List<Employee> employees) {
		this.employees = employees;
	}
	public Department getDept() {
		return dept;
	}
	public void setDept(Department dept) {
		this.dept = dept;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Date getBirth() {
		return birth;
	}
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
}
